//
//  AddFeedbackBtnCell.m
//  MIDI
//
//  Created by 邵子凡 on 15/11/4.
//  Copyright © 2015年 QXSX. All rights reserved.
//

#import "AddFeedbackBtnCell.h"
#import "AppConfig.h"

@interface AddFeedbackBtnCell ()

@property (weak, nonatomic) IBOutlet UIButton *complaintBtn;
@property (weak, nonatomic) IBOutlet UIButton *consultationBtn;
@property (weak, nonatomic) IBOutlet UIButton *BugBtn;
@property (weak, nonatomic) IBOutlet UIButton *otherBtn;

@end

@implementation AddFeedbackBtnCell

+(instancetype)cellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"AddFeedbackBtnCell";
    
    AddFeedbackBtnCell  *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"AddFeedbackBtnCell" owner:nil options:nil]firstObject] ;
    }
    
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    return cell;
}

- (void)awakeFromNib {
    
    //设置按钮圆角
    self.complaintBtn.layer.cornerRadius = 8;
    self.complaintBtn.tag = 1;
    //设置按钮点击事件
    [self.complaintBtn addTarget:self action:@selector(complaintBtn_Click:) forControlEvents:UIControlEventTouchUpInside];
    
    self.consultationBtn.layer.cornerRadius = 8;
    self.consultationBtn.tag = 2;
    //设置按钮点击事件
    [self.consultationBtn addTarget:self action:@selector(complaintBtn_Click:) forControlEvents:UIControlEventTouchUpInside];
    
    self.BugBtn.layer.cornerRadius = 8;
    self.BugBtn.tag = 3;
    //设置按钮点击事件
    [self.BugBtn addTarget:self action:@selector(complaintBtn_Click:) forControlEvents:UIControlEventTouchUpInside];
    
    self.otherBtn.layer.cornerRadius = 8;
    self.otherBtn.tag = 4;
    //设置按钮点击事件
    [self.otherBtn addTarget:self action:@selector(complaintBtn_Click:) forControlEvents:UIControlEventTouchUpInside];
    
}

//投诉按钮
- (void)complaintBtn_Click:(UIButton *)sender{
    
    sender.backgroundColor = [UIColor whiteColor];
    
    [sender setTitleColor:UIColorRGBA(115, 207, 202, 1) forState:UIControlStateNormal];
    
    sender.layer.borderWidth = 2.0;
    
    sender.layer.borderColor = [UIColor colorWithRed:19 / 255.0 green:208 / 255.0 blue:202 / 255.0 alpha:1].CGColor;
    
    for (UIButton * btn in self.contentView.subviews) {
        
        if (btn !=sender && [btn isKindOfClass:[UIButton class]] ) {
            
            btn.backgroundColor = UIColorRGBA(19, 208, 202, 1);
//            btn.backgroundColor = [UIColor redColor];
            [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        }
    }
    //代理传按钮
    
    if ([self.delegate respondsToSelector:@selector(uploadFeedbackBtn:)]) {
        
        [self.delegate uploadFeedbackBtn:sender];
    }
}

//咨询按钮
- (void)consultationBtn_Click:(UIButton *)sender{
    
    self.consultationBtn.backgroundColor = [UIColor whiteColor];
    [self.consultationBtn setTitleColor:UIColorRGBA(115, 207, 202, 1) forState:UIControlStateNormal];
    //设置边框
    self.consultationBtn.layer.borderWidth = 2.0;
    //设置边框颜色
    self.consultationBtn.layer.borderColor = [UIColor colorWithRed:115 / 255.0 green:207 / 255.0 blue:202 / 255.0 alpha:1].CGColor;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
